<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="app">
        <cpn1></cpn1>
    </div>




    <!-- 组件模板抽离 template -->
    <!-- 1、第一种写法 script标签，类型必须是text/x-template-->
    <script type="text/x-template" id="cpn">
        <div>
            <h2>我是标题</h2>
            <p>我是内容</p>
        </div>
    </script>

    <!-- 2、使用template标签 -->
    <template id="CPN">
        <div>
            <h2>我是标题</h2>
            <p>我是内容</p>
        </div>
    </template>



    <script>
        //1、注册一个全局组件
        Vue.component('cpn1', ({
            template: '#CPN'
        }))


        const vm = new Vue({
            el: '#app',
            data: {
                message: '我是你爹!'
            },
            methods: {}
        });
    </script>
</body>

</html>